package priv.lirenhe.dissertation.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import priv.lirenhe.dissertation.data_generator.DataHtml;

@Controller
public class DataHtmlController {
	private final static String webPageShowerJsp = "webPageShower";
	
	@RequestMapping("/query_data")
	public ModelAndView queryDataGetter(HttpServletRequest request,HttpServletResponse response){
		System.out.println("queryDataGetter 执行!");
		
		Map<String,String> paramsMap = null;
		ModelAndView modelAndView = null;
		
		paramsMap = new HashMap<String,String>();
		paramsMap = request.getParameterMap();
		
		List<String> list_Value = null;
				
		String queryStr = null;
		String pageIndex = null;
		queryStr = paramsMap.get("queryStr");
		pageIndex = paramsMap.get("pageIndex");
		if(queryStr != null && pageIndex != null){
			list_Value = DataHtml.getQueryData(queryStr, new Integer(pageIndex));
			for(String str : list_Value){
				System.out.println("==========="+str);
			}
		}
		
		modelAndView = new ModelAndView();
		modelAndView.addObject("list_value", list_Value);
		modelAndView.setViewName(webPageShowerJsp);
		
		return modelAndView;
		
	}
	
}
